# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

pkgname=('mpfr' 'mpfr-devel')
_pkgver=3.1.3
_patchlevel=p0
pkgver=${_pkgver}.${_patchlevel}
#pkgver=${_pkgver}
pkgrel=1
pkgdesc="Multiple-precision floating-point library"
arch=('i686' 'x86_64')
url="http://www.mpfr.org/"
license=('LGPL')
depends=('gmp>=5.0')
makedepends=('gmp-devel>=5.0')
source=(http://www.mpfr.org/mpfr-current/mpfr-${_pkgver}.tar.xz{,.asc}
        mpfr-3.1.2-msys2.patch)
md5sums=('6969398cd2fbc56a6af570b5273c56a9'
         'SKIP'
         '3b420803169cd9d0b56960c6032e0b09')

prepare() {
  cd "${srcdir}/${pkgname}-${_pkgver}"
  patch -p1 -i $srcdir/mpfr-3.1.2-msys2.patch

  autoreconf -fi
}

build() {
  cd "${srcdir}/${pkgname}-${_pkgver}"
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --enable-shared \
    --disable-static
  make
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd "${srcdir}/${pkgname}-${_pkgver}"
  make check
}

package_mpfr() {
  groups=('libraries')
  install=mpfr.install

  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/bin ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/share ${pkgdir}/usr/
}

package_mpfr-devel() {
  groups=('development')
  options=('staticlibs')
  depends=("mpfr=${pkgver}" 'gmp-devel')
  pkgdesc="MPFR headers and libraries"

  mkdir -p ${pkgdir}/usr
  cp -rf $srcdir/dest/usr/include ${pkgdir}/usr/
  cp -rf $srcdir/dest/usr/lib ${pkgdir}/usr/
}
